<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>v-if-else按条件显示</title>
</head>
<body>
  <!--模版语法-->
  <div id="app">
    <!--v-if-->
    <div class="info" v-if="Object.keys(info).length"> <!--空对象{}转boolean:true    0转boolean是false-->
      <h2>个人信息</h2>
      <ul>
        <li>姓名: {{info.name}}</li>
        <li>年龄: {{info.age}}</li>
        <li>{{Object.keys(info).length}}</li>
      </ul>
    </div>
    <!--v-else-->
    <div v-else>
      <h2>没有输入个人信息</h2>
      <p>请输入个人信息后查询</p>
    </div>
  </div>
  <script src="../lib/vue.js"></script>
  <script>
    // 使用vue
    const app = Vue.createApp({
      data: function(){
        return {
          // info: {}
          info: {name: "jj", age: 18}
        }
      }
      ,methods: {
      }
    }
    )
    // 挂载 
    app.mount("#app")

  </script>

</body>
</html>
